<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
      <el-form-item label="标准溶液名称" prop="bdrymcnd" label-width="110px">
        <el-input v-model="queryParams.bdrymcnd" placeholder="请输入标准溶液名称" clearable size="small"
          @keyup.enter.native="handleQuery" />
      </el-form-item>
      <el-form-item label="报告日期" prop="bgrq">
        <el-date-picker :editable="false" clearable size="small" v-model="queryParams.bgrq" type="date"
          value-format="yyyy-MM-dd" placeholder="选择报告日期">
        </el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
          v-hasPermi="['Laboratory_standard:standard:add']">新增</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="success" plain icon="el-icon-edit" size="mini" :disabled="single" @click="handleUpdate"
          v-hasPermi="['Laboratory_standard:standard:edit']">修改</el-button>
      </el-col>
      <el-col :span="1.5">
        <el-button type="danger" plain icon="el-icon-delete" size="mini" :disabled="multiple" @click="handleDelete"
          v-hasPermi="['Laboratory_standard:standard:remove']">删除</el-button>
      </el-col>
      <!--  <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['Laboratory_standard:standard:export']"
          >导出</el-button
        >
      </el-col> -->
      <el-col :span="1.5">
        <el-button type="warning" plain icon="el-icon-s-check" size="mini" :disabled="multiple" @click="handleCheck"
          v-hasPermi="['Laboratory_standard:standard:check']">审核</el-button>
      </el-col>
      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
    </el-row>

    <el-table v-loading="loading" :data="standardList" @selection-change="handleSelectionChange" max-height="550">
      <el-table-column type="selection" width="55" align="center" />
      <el-table-column label="序号" align="center" prop="id" width="100px" />
      <el-table-column label="标准溶液名称" align="center" prop="bdrymcnd" width="100px" />
      <el-table-column label="配制及标定执行标准" align="center" prop="pzbdbz" width="140px" />
      <el-table-column label="试剂用量" align="center" prop="sjyl" />
      <el-table-column label="配制总体积" align="center" prop="pzztj" width="90" />

      <el-table-column label="配制时间" align="center" prop="pzsj" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.pzsj, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column label="标定后实际浓度" align="center" prop="bdhsjnd" width="120px" />
      <el-table-column label="有效日期" align="center" prop="yxrq" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.yxrq, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <!-- <el-table-column label="报表编号" align="center" prop="bbbh" /> -->

      <!-- <el-table-column label="审核日期" align="center" prop="shrq" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.shrq, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column> -->
      <!-- <el-table-column label="两组八平行相对极差" align="center" prop="bpjc" /> -->
      <el-table-column label="标定日期" align="center" prop="bdrq" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.bdrq, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column label="配制人" align="center" prop="pzr" />
      <el-table-column label="审核人" align="center" prop="shrPerson" />
      <!-- <el-table-column label="环境温度" align="center" prop="hjwd" width="180">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.hjwd, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="基准试剂名称"
        align="center"
        prop="jzsjmc"
        width="180"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.jzsjmc, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="基准试剂浓度"
        align="center"
        prop="jzsjnd"
        width="180"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.jzsjnd, "{y}-{m}-{d}") }}</span>
        </template>
      </el-table-column> -->
      <!-- <el-table-column label="备注" align="center" prop="remark" /> -->
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" min-width="250px">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-view" @click="excelhandleView(scope.row)">导出</el-button>
          <el-button size="mini" type="text" icon="el-icon-view" @click="handleView(scope.row)">查看</el-button>
          <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)"
            v-hasPermi="['Laboratory_standard:standard:edit']">修改</el-button>
          <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)"
            v-hasPermi="['Laboratory_standard:standard:remove']">删除</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />

    <!-- 添加或修改标准滴定溶液配制及标定记录对话框 -->
    <el-dialog v-myFullscreen fullscreen :title="title" :visible.sync="open" width="900px" append-to-body
      custom-class="myDialog">
      <TableHeader @nameChange="nameChange" :data="{
          mainTitle: '标准滴定溶液配制及标定记录',
          company: '青岛崂山矿泉水有限公司',
          code: form.bbbh,
        }" />
      <el-form ref="form" :model="form" :rules="rules" label-width="140px">
        <el-row>
          <el-col :span="12">
            <el-form-item label="标准溶液名称" prop="bdrymcnd">
              <el-input v-model="form.bdrymcnd" placeholder="请输入标准溶液名称" :disabled="openDisabled" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="标准溶液配置浓度" prop="bzrynd">
              <el-input v-model="form.bzrynd" placeholder="请输入标准溶液配置浓度" :disabled="openDisabled" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="配制及标定执行标准" prop="pzbdbz">
              <el-input v-model="form.pzbdbz" placeholder="请输入配制及标定执行标准" :disabled="openDisabled" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="试剂用量" prop="sjyl">
              <el-input v-model="form.sjyl" placeholder="请输入试剂用量" :disabled="openDisabled" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="配制总体积" prop="pzztj">
              <el-input v-model="form.pzztj" placeholder="请输入配制总体积" :disabled="openDisabled" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="配制人" prop="pzr">
              <UserDialog @dialogChange="form.pzr = $event.label" :echoValue="form.pzr" :multiple="false"
                :openDisabled="openDisabled" />
              <!--              <el-select v-model="form.pzr" filterable allow-create placeholder="请选择配制人" style="width: 100%" :disabled="openDisabled">-->
              <!--                <el-option v-for="item in userList" :key="item.nickName" :label="item.nickName" :value="item.nickName" :disabled="openDisabled"></el-option>-->
              <!--              </el-select>-->
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="配制时间" prop="pzsj">
              <el-date-picker :editable="false" clearable v-model="form.pzsj" type="date" value-format="yyyy-MM-dd"
                placeholder="选择配制时间" :disabled="openDisabled">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <!-- <el-col :span="12">
              <el-form-item label="报告日期" prop="bgrq">
                <el-date-picker  :editable="false" clearable size="small"
                  v-model="form.bgrq"
                  type="date"
                  value-format="yyyy-MM-dd"
                  placeholder="选择报告日期" :disabled="openDisabled">
                </el-date-picker>
              </el-form-item>
          </el-col> -->
          <el-col :span="12">
            <el-form-item label="标定后实际浓度" prop="bdhsjnd">
              <el-input v-model="form.bdhsjnd" placeholder="请输入标定后实际浓度(mol/L)" :disabled="openDisabled" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="有效日期" prop="yxrq">
              <el-date-picker :editable="false" clearable v-model="form.yxrq" type="date" value-format="yyyy-MM-dd"
                placeholder="选择有效日期" :disabled="openDisabled">
              </el-date-picker>
            </el-form-item>
          </el-col>
          <!-- <el-col :span="12">
            <el-form-item label="标定日期" prop="bdrq">
              <el-date-picker  :editable="false"
                clearable
                v-model="form.bdrq"
                type="date"
                value-format="yyyy-MM-dd"
                placeholder="选择标定日期"
                :disabled="openDisabled"
              >
              </el-date-picker>
            </el-form-item>
          </el-col> -->
          <el-col :span="12">
            <el-form-item label="环境温度（℃）" prop="hjwd">
              <el-input v-model="form.hjwd" placeholder="请输入环境温度" :disabled="openDisabled" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="基准试剂名称" prop="jzsjmc">
              <el-input v-model="form.jzsjmc" placeholder="请输入基准试剂浓度" :disabled="openDisabled" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="基准试剂浓度" prop="jzsjnd">
              <el-input v-model="form.jzsjnd" placeholder="请输入基准试剂浓度" :disabled="openDisabled" />
            </el-form-item>
          </el-col>
        </el-row>
        <br />
        <el-divider content-position="center">标准滴定溶液配制及标定记录子信息</el-divider>
        <br />
        <!-- <el-row :gutter="10" class="mb8">
          <el-col :span="1.5">
            <el-button
              type="primary"
              icon="el-icon-plus"
              @click="handleAddQualityLabStandardSub"
              :disabled="openDisabled"
              >添加</el-button
            >
          </el-col>
          <el-col :span="1.5">
            <el-button
              type="danger"
              icon="el-icon-delete"
              size="mini"
              @click="handleDeleteQualityLabStandardSub"
              :disabled="openDisabled"
              >删除</el-button
            >
          </el-col>
        </el-row>
        <el-divider content-position="center"></el-divider> -->

        <el-row>
          <el-col :span="12">
            <el-table :data="qualityLabStandardSubList" :row-class-name="rowQualityLabStandardSubIndex" border
              @selection-change="handleQualityLabStandardSubSelectionChange" ref="qualityLabStandardSub">
              <!-- <el-table-column type="selection" width="50" align="center" /> -->
              <el-table-column label="" align="center" width="140">
                <template slot-scope="scope">
                  <!-- 第一组 -->
                  <el-row>
                    <el-col :span="24">
                      <el-input placeholder="1" :disabled="true" />
                    </el-col>
                    <el-col :span="24">
                      <el-input placeholder="2" :disabled="true" />
                    </el-col>
                    <el-col :span="24">
                      <el-input placeholder="3" :disabled="true" />
                    </el-col>
                    <el-col :span="24">
                      <el-input placeholder="4" :disabled="true" />
                    </el-col>
                    <el-col :span="24">
                      <el-input placeholder="平均值" :disabled="true" />
                    </el-col>
                  </el-row>
                  <!-- 第二组 -->
                  <el-row>
                    <el-col :span="24">
                      <el-input placeholder="1" :disabled="true" />
                    </el-col>
                    <el-col :span="24">
                      <el-input placeholder="2" :disabled="true" />
                    </el-col>
                    <el-col :span="24">
                      <el-input placeholder="3" :disabled="true" />
                    </el-col>
                    <el-col :span="24">
                      <el-input placeholder="4" :disabled="true" />
                    </el-col>
                    <el-col :span="24">
                      <el-input placeholder="平均值" :disabled="true" />
                    </el-col>
                  </el-row>
                </template>
              </el-table-column>
              <el-table-column label="消耗标准溶液的体积(mL)" align="center">
                <template slot-scope="scope">
                  <!-- 第一组 -->
                  <el-row>
                    <el-col :span="24">
                      <el-input @input="numChange" v-model="scope.row.tj11" placeholder="请输入消耗标准溶液的体积V1"
                        :disabled="openDisabled" />
                    </el-col>
                    <el-col :span="24">
                      <el-input @input="numChange" v-model="scope.row.tj12" placeholder="请输入消耗标准溶液的体积V2"
                        :disabled="openDisabled" />
                    </el-col>
                    <el-col :span="24">
                      <el-input @input="numChange" v-model="scope.row.tj13" placeholder="请输入消耗标准溶液的体积V3"
                        :disabled="openDisabled" />
                    </el-col>
                    <el-col :span="24">
                      <el-input @input="numChange" v-model="scope.row.tj14" placeholder="请输入消耗标准溶液的体积V4"
                        :disabled="openDisabled" />
                    </el-col>
                    <el-col :span="24">
                      <el-input @input="numChange" v-model="scope.row.avg1" placeholder="消耗标准溶液体积的平均值"
                        :disabled="openDisabled" />
                    </el-col>
                  </el-row>
                  <!-- 第二组 -->
                  <el-row>
                    <el-col :span="24">
                      <el-input @input="numChange" v-model="scope.row.tj21" placeholder="请输入消耗标准溶液的体积V1"
                        :disabled="openDisabled" />
                    </el-col>
                    <el-col :span="24">
                      <el-input @input="numChange" v-model="scope.row.tj22" placeholder="请输入消耗标准溶液的体积V2"
                        :disabled="openDisabled" />
                    </el-col>
                    <el-col :span="24">
                      <el-input @input="numChange" v-model="scope.row.tj23" placeholder="请输入消耗标准溶液的体积V3"
                        :disabled="openDisabled" />
                    </el-col>
                    <el-col :span="24">
                      <el-input @input="numChange" v-model="scope.row.tj24" placeholder="请输入消耗标准溶液的体积V4"
                        :disabled="openDisabled" />
                    </el-col>
                    <el-col :span="24">
                      <el-input @input="numChange" v-model="scope.row.avg2" placeholder="消耗标准溶液体积的平均值"
                        :disabled="openDisabled" />
                    </el-col>
                  </el-row>
                </template>
              </el-table-column>
              <el-table-column label="称取重量" align="center">
                <template slot-scope="scope">
                  <!-- 第一组 -->
                  <el-row>
                    <el-col :span="24">
                      <el-input @input="numChange" v-model="scope.row.zl11" placeholder="请输入称取重量m1"
                        :disabled="openDisabled" />
                    </el-col>
                    <el-col :span="24">
                      <el-input @input="numChange" v-model="scope.row.zl12" placeholder="请输入称取重量m2"
                        :disabled="openDisabled" />
                    </el-col>
                    <el-col :span="24">
                      <el-input @input="numChange" v-model="scope.row.zl13" placeholder="请输入称取重量m3"
                        :disabled="openDisabled" />
                    </el-col>
                    <el-col :span="24">
                      <el-input @input="numChange" v-model="scope.row.zl14" placeholder="请输入称取重量m4"
                        :disabled="openDisabled" />
                    </el-col>
                    <el-col :span="24">
                      <el-input @input="numChange" v-model="scope.row.zlAvg1" placeholder="称取重量的平均值"
                        :disabled="openDisabled" />
                    </el-col>
                  </el-row>
                  <!-- 第二组 -->
                  <el-row>
                    <el-col :span="24">
                      <el-input @input="numChange" v-model="scope.row.zl21" placeholder="请输入称取重量m1"
                        :disabled="openDisabled" />
                    </el-col>
                    <el-col :span="24">
                      <el-input @input="numChange" v-model="scope.row.zl22" placeholder="请输入称取重量m2"
                        :disabled="openDisabled" />
                    </el-col>
                    <el-col :span="24">
                      <el-input @input="numChange" v-model="scope.row.zl23" placeholder="请输入称取重量m3"
                        :disabled="openDisabled" />
                    </el-col>
                    <el-col :span="24">
                      <el-input @input="numChange" v-model="scope.row.zl24" placeholder="请输入称取重量m4"
                        :disabled="openDisabled" />
                    </el-col>
                    <el-col :span="24">
                      <el-input @input="numChange" v-model="scope.row.zlAvg2" placeholder="称取重量的平均值"
                        :disabled="openDisabled" />
                    </el-col>
                  </el-row>
                </template>
              </el-table-column>
              <el-table-column label="标定浓度" align="center">
                <template slot-scope="scope">
                  <!-- 第一组 -->
                  <el-row>
                    <el-col :span="24">
                      <el-input @input="numChange" v-model="scope.row.nd11" placeholder="" :disabled="openDisabled" />
                    </el-col>
                    <el-col :span="24">
                      <el-input @input="numChange" v-model="scope.row.nd12" placeholder="" :disabled="openDisabled" />
                    </el-col>
                    <el-col :span="24">
                      <el-input @input="numChange" v-model="scope.row.nd13" placeholder="" :disabled="openDisabled" />
                    </el-col>
                    <el-col :span="24">
                      <el-input @input="numChange" v-model="scope.row.nd14" placeholder="" :disabled="openDisabled" />
                    </el-col>
                    <el-col :span="24">
                      <el-input @input="numChange" v-model="scope.row.ndAvg1" placeholder="" :disabled="openDisabled" />
                    </el-col>
                  </el-row>
                  <!-- 第二组 -->
                  <el-row>
                    <el-col :span="24">
                      <el-input @input="numChange" v-model="scope.row.nd21" placeholder="" :disabled="openDisabled" />
                    </el-col>
                    <el-col :span="24">
                      <el-input @input="numChange" v-model="scope.row.nd22" placeholder="" :disabled="openDisabled" />
                    </el-col>
                    <el-col :span="24">
                      <el-input @input="numChange" v-model="scope.row.nd23" placeholder="" :disabled="openDisabled" />
                    </el-col>
                    <el-col :span="24">
                      <el-input @input="numChange" v-model="scope.row.nd24" placeholder="" :disabled="openDisabled" />
                    </el-col>
                    <el-col :span="24">
                      <el-input @input="numChange" v-model="scope.row.ndAvg2" placeholder="" :disabled="openDisabled" />
                    </el-col>
                  </el-row>
                </template>
              </el-table-column>
              <!-- <el-table-column
                label="序号"
                align="center"
                prop="index"
                width="50"
                v-if="false"
              /> -->
              <!-- <el-table-column label="编号" align="center">
                <template slot-scope="scope">
                  <el-input
                    v-model="scope.row.bh"
                    placeholder="请输入编号"
                    :disabled="openDisabled"
                  />
                </template>
              </el-table-column>

              <el-table-column label="消耗标准溶液的体积(mL)" prop="tj">
                <template slot-scope="scope">
                  <el-input
                    v-model="scope.row.tj"
                    placeholder="请输入体积"
                    :disabled="openDisabled"
                  />
                </template>
              </el-table-column>
              <el-table-column label="标定人" prop="bdr">
                <template slot-scope="scope">
                  <el-input
                    v-model="scope.row.bdr"
                    placeholder="请输入标定人"
                    :disabled="openDisabled"
                  />
                </template>
              </el-table-column>
              <el-table-column label="标定日期" prop="bdrq">
                <template slot-scope="scope">
                  <el-date-picker  :editable="false"
                    clearable
                    v-model="scope.row.bdrq"
                    type="date"
                    value-format="yyyy-MM-dd"
                    placeholder="选择标定日期"
                    :disabled="openDisabled"
                  >
                  </el-date-picker>
                </template>
              </el-table-column> -->
            </el-table>
          </el-col>
          <el-col :span="12">
            <br /><br /><br />
            <el-row>
              <el-col :span="24">
                <el-form-item label="标定人" prop="bdr">
                  <UserDialog @dialogChange="form.bdr = $event.label" :echoValue="form.bdr" :multiple="false"
                    :openDisabled="openDisabled" />
                  <!--                  <el-input v-model="form.bdr" placeholder="请输入标定人" :disabled="openDisabled" />-->
                </el-form-item>
              </el-col>
              <el-col :span="24">
                <el-form-item label="标定日期" prop="bdrq">
                  <el-date-picker :editable="false" clearable v-model="form.bdrq" type="date" value-format="yyyy-MM-dd"
                    placeholder="选择标定日期" :disabled="openDisabled" />
                </el-form-item>
              </el-col>
              <el-col :span="24">
                <el-form-item label="两组八平行相对极差" prop="bdrq">
                  <el-input v-model="form.bpjc" placeholder="请输入两组八平行相对极差" :disabled="openDisabled" />
                </el-form-item>
              </el-col>
            </el-row>
          </el-col>
        </el-row>

        <!-- 备注 -->
        <el-row>
          <el-col :span="24">
            <el-form-item label="备注" prop="remark">
              <el-input v-model="form.remark" placeholder="请输入备注" :disabled="openDisabled" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="12">
            <el-form-item label="审核人" prop="shrPerson">
              <el-input v-model="form.shrPerson" :disabled="true" />
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="审核日期" prop="shrq">
              <el-date-picker :editable="false" clearable v-model="form.shrq" type="date" value-format="yyyy-MM-dd"
                placeholder="选择审核日期" :disabled="openDisabled">
              </el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer" v-if="!openDisabled">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
  import {
    listStandard,
    getStandard,
    delStandard,
    addStandard,
    updateStandard,
    checkStandard
  } from "@/api/quality/laboratory/standard";
  import { getInfo } from "@/api/login";
  import { listUser } from "@/api/system/user";

  export default {
    name: "Standard",
    data() {
      return {
        //弹窗是否禁止编辑
        openDisabled: true,
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 子表选中数据
        checkedQualityLabStandardSub: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 标准滴定溶液配制及标定记录表格数据
        standardList: [],
        // 标准滴定溶液配制及标定记录子表格数据
        qualityLabStandardSubList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 50,
          bdrymcnd: null,
          bgrq: null,
        },
        // 表单参数
        form: {},
        // 表单校验
        rules: {},
        /* 当前用户名 */
        nickName: "",
        userList: [],
      };
    },
    created() {
      this.getList();
      this.queryUserList();
      this.getDicts("laboratory_standard_yt").then((response) => {
        this.laboratory_standard_yt = response.data;
      });
    },
    methods: {
      /** 查询标准滴定溶液配制及标定记录列表 */
      getList() {
        this.loading = true;
        listStandard(this.queryParams).then((response) => {
          this.standardList = response.rows;
          this.total = response.total;
          this.loading = false;
        });
      },
      laboratory_Biology_yt_Format(row, column) {
        return this.selectDictLabel(this.laboratory_standard_yt, row.bh);
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
          id: null,
          bdrymcnd: null,
          bzrynd: null,
          pzbdbz: null,
          sjyl: null,
          pzztj: null,
          pzr: this.nickName,
          pzsj: null,
          bgrq: null,
          bdhsjnd: null,
          yxrq: null,
          bbbh: "LK-QF-LS1-10-015-11-05",
          shrPerson: null,
          shrq: null,
          bpjc: null,
          bdr: null,
          bdrq: null,
          hjwd: null,
          jzsjmc: null,
          jzsjnd: null,
          remark: null,
          createBy: null,
          createTime: null,
          updateBy: null,
          updateTime: null,
          delFlag: null,
        };
        this.qualityLabStandardSubList = [];
        this.resetForm("form");
      },
      //数值发生变化时
      numChange() {
        for (let item of this.qualityLabStandardSubList) {
          item.avg1 = ((Number(item.tj11) + Number(item.tj12) + Number(item.tj13) + Number(item.tj14)) / 4).toFixed(2)
          item.avg2 = ((Number(item.tj21) + Number(item.tj22) + Number(item.tj23) + Number(item.tj24)) / 4).toFixed(2)
          item.zlAvg1 = ((Number(item.zl11) + Number(item.zl12) + Number(item.zl13) + Number(item.zl14)) / 4).toFixed(2)
          item.zlAvg2 = ((Number(item.zl21) + Number(item.zl22) + Number(item.zl23) + Number(item.zl24)) / 4).toFixed(2)
          // item.ndAvg1 = ((Number(item.nd11) + Number(item.nd12) + Number(item.nd13) + Number(item.nd14)) / 4).toFixed(2)
          // item.ndAvg2 = ((Number(item.nd21) + Number(item.nd22) + Number(item.nd23) + Number(item.nd24)) / 4).toFixed(2)
          item.nd11 = (Number(item.zl11) / (item.tj11 ? Number(item.tj11) : 1) * 0.05299).toFixed(2)
          item.nd12 = (Number(item.zl12) / (item.tj12 ? Number(item.tj12) : 1) * 0.05299).toFixed(2)
          item.nd13 = (Number(item.zl13) / (item.tj13 ? Number(item.tj13) : 1) * 0.05299).toFixed(2)
          item.nd14 = (Number(item.zl14) / (item.tj14 ? Number(item.tj14) : 1) * 0.05299).toFixed(2)
          item.nd21 = (Number(item.zl21) / (item.tj21 ? Number(item.tj21) : 1) * 0.05299).toFixed(2)
          item.nd22 = (Number(item.zl22) / (item.tj22 ? Number(item.tj22) : 1) * 0.05299).toFixed(2)
          item.nd23 = (Number(item.zl23) / (item.tj23 ? Number(item.tj23) : 1) * 0.05299).toFixed(2)
          item.nd24 = (Number(item.zl24) / (item.tj24 ? Number(item.tj24) : 1) * 0.05299).toFixed(2)
        }
        for (let item of this.qualityLabStandardSubList) {
          item.ndAvg1 = ((Number(item.nd11) + Number(item.nd12) + Number(item.nd13) + Number(item.nd14)) / 4).toFixed(2)
          item.ndAvg2 = ((Number(item.nd21) + Number(item.nd22) + Number(item.nd23) + Number(item.nd24)) / 4).toFixed(2)
        }
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map((item) => item.id);
        this.single = selection.length !== 1;
        this.multiple = !selection.length;
      },
      /** 新增按钮操作 */
      handleAdd() {
        this.reset();
        this.openDisabled = false;
        this.open = true;
        this.form.pzr = this.nickName;
        this.form.bdr = this.nickName;
        this.title = "添加标准滴定溶液配制及标定记录";
        this.handleAddQualityLabStandardSub();
      },
      /** 修改按钮操作 */
      handleUpdate(row) {
        this.reset();
        this.openDisabled = false;
        const id = row.id || this.ids;
        getStandard(id).then((response) => {
          this.form = response.data;
          this.qualityLabStandardSubList =
            response.data.qualityLabStandardSubList;
          this.open = true;
          this.title = "修改标准滴定溶液配制及标定记录";
        });
      },
      /** 查看按钮 */
      handleView(row) {
        this.reset();
        this.openDisabled = true;
        const id = row.id || this.ids;
        getStandard(id).then((response) => {
          this.form = response.data;
          this.qualityLabStandardSubList =
            response.data.qualityLabStandardSubList;
          this.open = true;
          this.title = "查看标准滴定溶液配制及标定记录";
        });
      },
      /** 提交按钮 */
      submitForm() {
        this.$refs["form"].validate((valid) => {
          if (valid) {
            this.form.qualityLabStandardSubList = this.qualityLabStandardSubList;
            /**打开遮罩层*/
            const rLoading = this.openLoading();
            if (this.form.id != null) {
              updateStandard(this.form)
                .then((response) => {
                  /**成功后执行关闭遮罩层*/
                  rLoading.close();
                  this.msgSuccess("修改成功");
                  this.open = false;
                  this.getList();
                })
                .catch((error) => {
                  /**请求异常后执行关闭遮罩层*/
                  rLoading.close();
                });
            } else {
              addStandard(this.form)
                .then((response) => {
                  /**成功后执行关闭遮罩层*/
                  rLoading.close();
                  this.msgSuccess("新增成功");
                  this.open = false;
                  this.getList();
                })
                .catch((error) => {
                  /**请求异常后执行关闭遮罩层*/
                  rLoading.close();
                });
            }
          }
        });
      },
      /** 删除按钮操作 */
      handleDelete(row) {
        const ids = row.id || this.ids;
        this.$confirm(
          '是否确认删除标准滴定溶液配制及标定记录编号为"' + ids + '"的数据项?',
          "警告",
          {
            confirmButtonText: "确定",
            cancelButtonText: "取消",
            type: "warning",
          }
        )
          .then(function () {
            return delStandard(ids);
          })
          .then(() => {
            this.getList();
            this.msgSuccess("删除成功");
          })
          .catch(() => { });
      },
      /** 标准滴定溶液配制及标定记录子序号 */
      rowQualityLabStandardSubIndex({ row, rowIndex }) {
        row.index = rowIndex + 1;
      },
      /** 标准滴定溶液配制及标定记录子添加按钮操作 */
      handleAddQualityLabStandardSub() {
        let obj = {};
        obj.tj11 = "";
        obj.tj12 = "";
        obj.tj13 = "";
        obj.tj14 = "";
        obj.avg1 = "";
        obj.tj21 = "";
        obj.tj22 = "";
        obj.tj23 = "";
        obj.tj24 = "";
        obj.avg2 = "";
        obj.zl11 = "";
        obj.zl12 = "";
        obj.zl13 = "";
        obj.zl14 = "";
        obj.zlAvg1 = "";
        obj.zl21 = "";
        obj.zl22 = "";
        obj.zl23 = "";
        obj.zl24 = "";
        obj.zlAvg2 = "";
        obj.nd11 = "";
        obj.nd12 = "";
        obj.nd13 = "";
        obj.nd14 = "";
        obj.ndAvg1 = "";
        obj.nd21 = "";
        obj.nd22 = "";
        obj.nd23 = "";
        obj.nd24 = "";
        obj.ndAvg2 = "";
        obj.tj = "";
        obj.remark = "";
        obj.bdr = "";
        obj.bdrq = "";
        this.qualityLabStandardSubList.push(obj);
      },
      /** 标准滴定溶液配制及标定记录子删除按钮操作 */
      handleDeleteQualityLabStandardSub() {
        if (this.checkedQualityLabStandardSub.length == 0) {
          this.$alert(
            "请先选择要删除的标准滴定溶液配制及标定记录子数据",
            "提示",
            { confirmButtonText: "确定" }
          );
        } else {
          this.qualityLabStandardSubList.splice(
            this.checkedQualityLabStandardSub[0].index - 1,
            1
          );
        }
      },
      /** 单选框选中数据 */
      handleQualityLabStandardSubSelectionChange(selection) {
        if (selection.length > 1) {
          this.$refs.qualityLabStandardSub.clearSelection();
          this.$refs.qualityLabStandardSub.toggleRowSelection(selection.pop());
        } else {
          this.checkedQualityLabStandardSub = selection;
        }
      },
      /** 导出按钮操作 */
      handleExport() {
        this.download(
          "Laboratory_standard/standard/export",
          {
            ...this.queryParams,
          },
          `Laboratory_standard_standard.xlsx`
        );
      },
      excelhandleView(row) {
        this.download(
          "Laboratory/standard/exportexcel?id=" + row.id,
          {
            ...this.queryParams,
          },
          "标准滴定溶液配制及标定记录" + this.parseTime(new Date()) + ".xlsx"
        );
      },
      //接收编号
      nameChange(e) {
        this.form.bbbh = e;
      },
      /** 审核按钮操作 */
      handleCheck(row) {
        /* 审核 */
        this.ids.forEach((id) => {
          getStandard(id).then((response) => {
            if (
              response.data.shrPerson != null &&
              response.data.shrPerson != ""
            ) {
              this.msgError(
                '编号为"' + id + '"的数据项已审核完成，无需重复审核！'
              );
            } else {
              let obj = {};
              obj.id = id;
              obj.shrPerson = this.nickName;
              obj.shrq = this.parseTime(new Date());
              /* 修改 */
              checkStandard(obj).then((response) => {
                this.msgSuccess('编号为"' + id + '"的数据项审核成功！');
                this.getList();
              });
            }
          });
        });
      },
      /* 查询用户列表 */
      queryUserList() {
        listUser().then((response) => {
          this.userList = response.rows;
        });
        getInfo().then((response) => {
          this.nickName = response.user.nickName;
        });
      },
    },
  };
</script>